<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <button @click="updata">修改msg</button>
    <br />
    <input type="text" v-model="username" />
    <div class="username">{{ username }}</div>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data() {
    return {
      msg: 'hello world',
      username: 'tom'
    }
  },
  methods: {
    updata() {
      if (this.msg === 'hello world') {
        this.msg = '这是修改后的msg'
      } else {
        this.msg = 'hello world'
      }
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
.hello {
  h1 {
    color: red;
  }
}
</style>
